home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blanker / source / blankers / fractal / blank.c next >
C/C++ Source or Header  |  1993-08-15  |  2KB  |  63 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuition.h>
  3. #include <dos/dos.h>
  4.  
  5. #include <clib/exec_protos.h>
  6. #include <clib/intuition_protos.h>
  7. #include <clib/graphics_protos.h>
  8. #include <clib/alib_protos.h>
  9.  
  10. #include <math.h>
  11. #include "/defs.h"
  12. #include "/utility.h"
  13.  
  14. extern    ULONG    Mode, Depth;
  15.  
  16. VOID FracBlank( struct Screen *Scr, UWORD Wid, UWORD Hei )
  17. {
  18.     float    x = 0, y = 0, xx, yy, a, b, c;
  19.     SHORT    i, xe, ye, flg_end = FALSE, mod = ( 1L << Depth ) - 1;
  20.  
  21.     SetRast(&( Scr->RastPort ), 0 );
  22.     ScreenToFront( Scr );
  23.  
  24.     a = (float)RangeRand( 1000 ) / 10 - 50.0;
  25.     do b = (float)RangeRand( 1000 ) / 10 - 50.0;
  26.     while( b == 0.0 );
  27.     c = (float)RangeRand( 1000 ) / 10 - 50.0;
  28.  
  29.     for( i = 0; i < 5000 && !flg_end; i++ ) {
  30.         if(!( i % 50 )) flg_end = ( SetSignal( 0L, 0L ) & SIGBREAKF_CTRL_C );
  31.  
  32.         if( x < 0 ) xx = y + sqrt( fabs( b * x - c ));
  33.         else xx = y - sqrt( fabs( b * x - c ));
  34.         yy = a - x;
  35.         xe = Wid / 2 + (SHORT)x;
  36.         ye = Hei / 2 + (SHORT)y;
  37.  
  38.         SetAPen(&( Scr->RastPort ), ( ReadPixel(&( Scr->RastPort ), xe, ye ) + 1 ) % mod + 1 );
  39.         WritePixel(&( Scr->RastPort ), xe, ye );
  40.  
  41.         x = xx;
  42.         y = yy;
  43.     }
  44. }
  45.  
  46. VOID blank( VOID )
  47. {
  48.     struct Screen *Scr;
  49.  
  50.     if( Scr = OpenScreenTags( NULL, SA_Depth, Depth, SA_Overscan, OSCAN_STANDARD, SA_DisplayID, Mode, SA_Quiet,
  51.         TRUE, SA_Behind, TRUE, TAG_DONE )) {
  52.  
  53.         SetRGB4(&( Scr->ViewPort ), 0, 0, 0, 0 );
  54.         BlankMousePointer();
  55.  
  56.         while(!(SetSignal(0,0) & SIGBREAKF_CTRL_C )) FracBlank( Scr, Scr->Width, Scr->Height );
  57.  
  58.         SetSignal( 0L, SIGBREAKF_CTRL_C );
  59.         UnblankMousePointer();
  60.         CloseScreen( Scr );
  61.     }
  62. }
  63.